<?php
XJConfLoader::load('definitions.TagDefinition');
/**
 * Container for all tag definitions in one namespace
 * 
 * @author Stephan Schmidt <stephan.schmidt@schlund.de>
 */
class NamespaceDefinition
{
    /**
     * list of tag definitions
     * 
     * @var  array<String,TagDefinition>
     */
	private $tagDefinitions = array();
	
	/**
	 * URI of this namespace
	 * 
	 * @var  string
	 */
    private $namespaceURI = null;
    
   /**    
    * Constructor for a namespace definition
    * 
    * @param  string  namespaceURI  URI of the new namespace
    */
    public function __construct($namespaceURI)
    {
        $this->namespaceURI = $namespaceURI;
    }
    
   /**
    * Add a new tag definition
    * 
    * @param  TagDefinition  $tagDefinition
    */
    public function addTagDefinition(TagDefinition $tagDefinition)
    {
        $this->tagDefinitions[$tagDefinition->getTagName()] = $tagDefinition;
    }

   /**
    * Count the number of defined tags
    * 
    * @return  int  number of defined tags
    */
    public function countTagDefinitions()
    {
    	return count($this->tagDefinitions);
    }

   /**
    * Check, whether a tag has been defined
    * 
    * @param   string   $tagName  name of the tag
    * @return  boolean  true, if the tag has been defined, false otherwise
    */
    public function isDefined($tagName)
    {
    	return isset($this->tagDefinitions[$tagName]);
    }

   /**
    * Get the definition of a tag
    * 
    * @param   tagName name of the tag
    * @return  TagDefinition
    */
    public function getDefinition($tagName)
    {
        if ($this->isDefined($tagName) == true) {
            return $this->tagDefinitions[$tagName];
        }
        
        return null;
    }

    /**
     * Get the URI for this namespace
     * 
     * @return  string
     */
    public function getNamespaceURI()
    {
    	return $this->namespaceURI;
    }    
}
?>